package org.ycx.doc.dao.auto;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.ycx.doc.dao.model.DocGroup;
import org.ycx.doc.dao.model.DocGroupExample;

public interface DocGroupMapper {
    @SelectProvider(type=DocGroupSqlProvider.class, method="countByExample")
    long countByExample(DocGroupExample example);

    @DeleteProvider(type=DocGroupSqlProvider.class, method="deleteByExample")
    int deleteByExample(DocGroupExample example);

    @Delete({
        "delete from doc_group",
        "where GROUP_ID = #{groupId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer groupId);

    @Insert({
        "insert into doc_group (GROUP_NAME, GROUP_DESC, ",
        "CREATE_TS, CREATE_UID, ",
        "UPDATE_TS, UPDATE_UID)",
        "values (#{groupName,jdbcType=VARCHAR}, #{groupDesc,jdbcType=VARCHAR}, ",
        "#{createTs,jdbcType=DATE}, #{createUid,jdbcType=INTEGER}, ",
        "#{updateTs,jdbcType=DATE}, #{updateUid,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="groupId", before=false, resultType=Integer.class)
    int insert(DocGroup record);

    @InsertProvider(type=DocGroupSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="groupId", before=false, resultType=Integer.class)
    int insertSelective(DocGroup record);

    @SelectProvider(type=DocGroupSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="GROUP_ID", property="groupId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="GROUP_NAME", property="groupName", jdbcType=JdbcType.VARCHAR),
        @Result(column="GROUP_DESC", property="groupDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    List<DocGroup> selectByExample(DocGroupExample example);

    @Select({
        "select",
        "GROUP_ID, GROUP_NAME, GROUP_DESC, CREATE_TS, CREATE_UID, UPDATE_TS, UPDATE_UID",
        "from doc_group",
        "where GROUP_ID = #{groupId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="GROUP_ID", property="groupId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="GROUP_NAME", property="groupName", jdbcType=JdbcType.VARCHAR),
        @Result(column="GROUP_DESC", property="groupDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    DocGroup selectByPrimaryKey(Integer groupId);

    @UpdateProvider(type=DocGroupSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") DocGroup record, @Param("example") DocGroupExample example);

    @UpdateProvider(type=DocGroupSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") DocGroup record, @Param("example") DocGroupExample example);

    @UpdateProvider(type=DocGroupSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DocGroup record);

    @Update({
        "update doc_group",
        "set GROUP_NAME = #{groupName,jdbcType=VARCHAR},",
          "GROUP_DESC = #{groupDesc,jdbcType=VARCHAR},",
          "CREATE_TS = #{createTs,jdbcType=DATE},",
          "CREATE_UID = #{createUid,jdbcType=INTEGER},",
          "UPDATE_TS = #{updateTs,jdbcType=DATE},",
          "UPDATE_UID = #{updateUid,jdbcType=INTEGER}",
        "where GROUP_ID = #{groupId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DocGroup record);
}